#include<bits/stdc++.h>
using namespace std;
long long n,l,r,sss,ss=-100,t;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	if(r<l+n)
	{
		if(((l/n+1)*n)>r)
		{
			if((r%n)>(l%n))
			cout<<r%n;
			else
			cout<<l%n;
		}
		else
		{
			cout<<r%n;
		}
	}
	else
	{
		cout<<n-1;
	}
	return 0;
}
